<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="140px">
      <el-form-item label="监察对象姓名" prop="monitoringmanName">
        <el-input
          v-model="queryParams.monitoringmanName"
          placeholder="请输入监察对象姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象出生年月" prop="monitoringBri">
        <el-input
          v-model="queryParams.monitoringBri"
          placeholder="请输入监察对象出生年月"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象民族" prop="monitoringNation">
        <el-input
          v-model="queryParams.monitoringNation"
          placeholder="请输入监察对象民族"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象籍贯" prop="monitoringNative">
        <el-input
          v-model="queryParams.monitoringNative"
          placeholder="请输入监察对象籍贯"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象参加工作时间" prop="monitoringWorktime">
        <el-input
          v-model="queryParams.monitoringWorktime"
          placeholder="请输入监察对象参加工作时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象政治面貌" prop="monitoringPolitical">
        <el-input
          v-model="queryParams.monitoringPolitical"
          placeholder="请输入监察对象政治面貌"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象入党时间" prop="monitoringJointime">
        <el-input
          v-model="queryParams.monitoringJointime"
          placeholder="请输入监察对象入党时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象职级" prop="monitoringRank">
        <el-input
          v-model="queryParams.monitoringRank"
          placeholder="请输入监察对象职级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象社会职务" prop="monitoringSocialposition">
        <el-input
          v-model="queryParams.monitoringSocialposition"
          placeholder="请输入监察对象社会职务"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象单位类型" prop="monitoringCategory">
        <el-input
          v-model="queryParams.monitoringCategory"
          placeholder="请输入监察对象单位类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象身份类型" prop="monitoringIdentity">
        <el-input
          v-model="queryParams.monitoringIdentity"
          placeholder="请输入监察对象身份类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象处境护照" prop="monitoringExitpassport">
        <el-input
          v-model="queryParams.monitoringExitpassport"
          placeholder="请输入监察对象处境护照"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象文化程度" prop="monitoringDegreeofeducation">
        <el-input
          v-model="queryParams.monitoringDegreeofeducation"
          placeholder="请输入监察对象文化程度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象毕业院校" prop="monitoringUniversity">
        <el-input
          v-model="queryParams.monitoringUniversity"
          placeholder="请输入监察对象毕业院校"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象现任职务" prop="monitoringCurrentposition">
        <el-input
          v-model="queryParams.monitoringCurrentposition"
          placeholder="请输入监察对象现任职务"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象身份证号" prop="monitoringIdnumber">
        <el-input
          v-model="queryParams.monitoringIdnumber"
          placeholder="请输入监察对象身份证号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象家庭住址" prop="monitoringAddress">
        <el-input
          v-model="queryParams.monitoringAddress"
          placeholder="请输入监察对象家庭住址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象简历" prop="monitoringBiographicalnotes">
        <el-input
          v-model="queryParams.monitoringBiographicalnotes"
          placeholder="请输入监察对象简历"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象联系方式" prop="monitoringPhonenum">
        <el-input
          v-model="queryParams.monitoringPhonenum"
          placeholder="请输入监察对象联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="对象家庭称谓" prop="monitoringFamilyTitle">
        <el-input
          v-model="queryParams.monitoringFamilyTitle"
          placeholder="请输入对象家庭称谓"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="家庭成员姓名" prop="monitoringFamilyName">
        <el-input
          v-model="queryParams.monitoringFamilyName"
          placeholder="请输入家庭成员姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="家庭成员年龄" prop="monitoringFamilyAge">
        <el-input
          v-model="queryParams.monitoringFamilyAge"
          placeholder="请输入家庭成员年龄"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="家庭成员政治面貌" prop="monitoringFamilyPolitical">
        <el-input
          v-model="queryParams.monitoringFamilyPolitical"
          placeholder="请输入家庭成员政治面貌"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="家庭成员工作单位" prop="monitoringFamilyWorkprofessional">
        <el-input
          v-model="queryParams.monitoringFamilyWorkprofessional"
          placeholder="请输入家庭成员工作单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="监察对象现任单位" prop="monitoringCurrentpositionunit">
        <el-input
          v-model="queryParams.monitoringCurrentpositionunit"
          placeholder="请输入监察对象现任单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="填表人" prop="monitoringFilledby">
        <el-input
          v-model="queryParams.monitoringFilledby"
          placeholder="请输入填表人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="填表时间" prop="monitoringFilledtime">
        <el-input
          v-model="queryParams.monitoringFilledtime"
          placeholder="请输入填表时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:monitoringmanList:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:monitoringmanList:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:monitoringmanList:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:monitoringmanList:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="monitoringmanListList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="监察对象姓名" align="center" prop="monitoringmanName" />
      <el-table-column label="监察对象性别" align="center" prop="monitoringSex" />
      <el-table-column label="监察对象出生年月" align="center" prop="monitoringBri" />
      <el-table-column label="监察对象民族" align="center" prop="monitoringNation" />
      <el-table-column label="监察对象籍贯" align="center" prop="monitoringNative" />
      <el-table-column label="监察对象参加工作时间" align="center" prop="monitoringWorktime" />
      <el-table-column label="监察对象政治面貌" align="center" prop="monitoringPolitical" />
      <el-table-column label="监察对象入党时间" align="center" prop="monitoringJointime" />
      <el-table-column label="监察对象职级" align="center" prop="monitoringRank" />
      <el-table-column label="监察对象社会职务" align="center" prop="monitoringSocialposition" />
      <el-table-column label="监察对象单位类型" align="center" prop="monitoringCategory" />
      <el-table-column label="监察对象身份类型" align="center" prop="monitoringIdentity" />
      <el-table-column label="监察对象处境护照" align="center" prop="monitoringExitpassport" />
      <el-table-column label="监察对象文化程度" align="center" prop="monitoringDegreeofeducation" />
      <el-table-column label="监察对象毕业院校" align="center" prop="monitoringUniversity" />
      <el-table-column label="监察对象现任职务" align="center" prop="monitoringCurrentposition" />
      <el-table-column label="监察对象身份证号" align="center" prop="monitoringIdnumber" />
      <el-table-column label="监察对象家庭住址" align="center" prop="monitoringAddress" />
      <el-table-column label="监察对象简历" align="center" prop="monitoringBiographicalnotes" />
      <el-table-column label="监察对象联系方式" align="center" prop="monitoringPhonenum" />
      <el-table-column label="对象家庭称谓" align="center" prop="monitoringFamilyTitle" />
      <el-table-column label="家庭成员姓名" align="center" prop="monitoringFamilyName" />
      <el-table-column label="家庭成员年龄" align="center" prop="monitoringFamilyAge" />
      <el-table-column label="家庭成员政治面貌" align="center" prop="monitoringFamilyPolitical" />
      <el-table-column label="家庭成员工作单位" align="center" prop="monitoringFamilyWorkprofessional" />
      <el-table-column label="监察对象现任单位" align="center" prop="monitoringCurrentpositionunit" />
      <el-table-column label="填表人" align="center" prop="monitoringFilledby" />
      <el-table-column label="填表时间" align="center" prop="monitoringFilledtime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:monitoringmanList:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:monitoringmanList:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="handleDownloadQRCode(scope.row)"
            v-hasPermi="['system:monitoringmanList:query']"
          >下载二维码</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改监察对象表对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-form-item label="监察对象姓名" prop="monitoringmanName">
          <el-input v-model="form.monitoringmanName" placeholder="请输入监察对象姓名" />
        </el-form-item>
        <el-form-item label="监察对象出生年月" prop="monitoringBri">
          <el-input v-model="form.monitoringBri" placeholder="请输入监察对象出生年月" />
        </el-form-item>
        <el-form-item label="监察对象民族" prop="monitoringNation">
          <el-input v-model="form.monitoringNation" placeholder="请输入监察对象民族" />
        </el-form-item>
        <el-form-item label="监察对象籍贯" prop="monitoringNative">
          <el-input v-model="form.monitoringNative" placeholder="请输入监察对象籍贯" />
        </el-form-item>
        <el-form-item label="监察对象参加工作时间" prop="monitoringWorktime">
          <el-input v-model="form.monitoringWorktime" placeholder="请输入监察对象参加工作时间" />
        </el-form-item>
        <el-form-item label="监察对象政治面貌" prop="monitoringPolitical">
          <el-input v-model="form.monitoringPolitical" placeholder="请输入监察对象政治面貌" />
        </el-form-item>
        <el-form-item label="监察对象入党时间" prop="monitoringJointime">
          <el-input v-model="form.monitoringJointime" placeholder="请输入监察对象入党时间" />
        </el-form-item>
        <el-form-item label="监察对象职级" prop="monitoringRank">
          <el-input v-model="form.monitoringRank" placeholder="请输入监察对象职级" />
        </el-form-item>
        <el-form-item label="监察对象社会职务" prop="monitoringSocialposition">
          <el-input v-model="form.monitoringSocialposition" placeholder="请输入监察对象社会职务" />
        </el-form-item>
        <el-form-item label="监察对象单位类型" prop="monitoringCategory">
          <el-input v-model="form.monitoringCategory" placeholder="请输入监察对象单位类型" />
        </el-form-item>
        <el-form-item label="监察对象身份类型" prop="monitoringIdentity">
          <el-input v-model="form.monitoringIdentity" placeholder="请输入监察对象身份类型" />
        </el-form-item>
        <el-form-item label="监察对象处境护照" prop="monitoringExitpassport">
          <el-input v-model="form.monitoringExitpassport" placeholder="请输入监察对象处境护照" />
        </el-form-item>
        <el-form-item label="监察对象文化程度" prop="monitoringDegreeofeducation">
          <el-input v-model="form.monitoringDegreeofeducation" placeholder="请输入监察对象文化程度" />
        </el-form-item>
        <el-form-item label="监察对象毕业院校" prop="monitoringUniversity">
          <el-input v-model="form.monitoringUniversity" placeholder="请输入监察对象毕业院校" />
        </el-form-item>
        <el-form-item label="监察对象现任职务" prop="monitoringCurrentposition">
          <el-input v-model="form.monitoringCurrentposition" placeholder="请输入监察对象现任职务" />
        </el-form-item>
        <el-form-item label="监察对象身份证号" prop="monitoringIdnumber">
          <el-input v-model="form.monitoringIdnumber" placeholder="请输入监察对象身份证号" />
        </el-form-item>
        <el-form-item label="监察对象家庭住址" prop="monitoringAddress">
          <el-input v-model="form.monitoringAddress" placeholder="请输入监察对象家庭住址" />
        </el-form-item>
        <el-form-item label="监察对象简历" prop="monitoringBiographicalnotes">
          <el-input v-model="form.monitoringBiographicalnotes" placeholder="请输入监察对象简历" />
        </el-form-item>
        <el-form-item label="监察对象联系方式" prop="monitoringPhonenum">
          <el-input v-model="form.monitoringPhonenum" placeholder="请输入监察对象联系方式" />
        </el-form-item>
        <el-form-item label="对象家庭称谓" prop="monitoringFamilyTitle">
          <el-input v-model="form.monitoringFamilyTitle" placeholder="请输入对象家庭称谓" />
        </el-form-item>
        <el-form-item label="家庭成员姓名" prop="monitoringFamilyName">
          <el-input v-model="form.monitoringFamilyName" placeholder="请输入家庭成员姓名" />
        </el-form-item>
        <el-form-item label="家庭成员年龄" prop="monitoringFamilyAge">
          <el-input v-model="form.monitoringFamilyAge" placeholder="请输入家庭成员年龄" />
        </el-form-item>
        <el-form-item label="家庭成员政治面貌" prop="monitoringFamilyPolitical">
          <el-input v-model="form.monitoringFamilyPolitical" placeholder="请输入家庭成员政治面貌" />
        </el-form-item>
        <el-form-item label="家庭成员工作单位" prop="monitoringFamilyWorkprofessional">
          <el-input v-model="form.monitoringFamilyWorkprofessional" placeholder="请输入家庭成员工作单位" />
        </el-form-item>
        <el-form-item label="监察对象现任单位" prop="monitoringCurrentpositionunit">
          <el-input v-model="form.monitoringCurrentpositionunit" placeholder="请输入监察对象现任单位" />
        </el-form-item>
        <el-form-item label="填表人" prop="monitoringFilledby">
          <el-input v-model="form.monitoringFilledby" placeholder="请输入填表人" />
        </el-form-item>
        <el-form-item label="填表时间" prop="monitoringFilledtime">
          <el-input v-model="form.monitoringFilledtime" placeholder="请输入填表时间" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listMonitoringmanList, getMonitoringmanList, delMonitoringmanList, addMonitoringmanList, updateMonitoringmanList } from "@/api/system/monitoringmanList";

export default {
  name: "MonitoringmanList",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 监察对象表表格数据
      monitoringmanListList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        monitoringmanName: null,
        monitoringSex: null,
        monitoringBri: null,
        monitoringNation: null,
        monitoringNative: null,
        monitoringWorktime: null,
        monitoringPolitical: null,
        monitoringJointime: null,
        monitoringRank: null,
        monitoringSocialposition: null,
        monitoringCategory: null,
        monitoringIdentity: null,
        monitoringExitpassport: null,
        monitoringDegreeofeducation: null,
        monitoringUniversity: null,
        monitoringCurrentposition: null,
        monitoringIdnumber: null,
        monitoringAddress: null,
        monitoringBiographicalnotes: null,
        monitoringPhonenum: null,
        monitoringFamilyTitle: null,
        monitoringFamilyName: null,
        monitoringFamilyAge: null,
        monitoringFamilyPolitical: null,
        monitoringFamilyWorkprofessional: null,
        monitoringCurrentpositionunit: null,
        monitoringFilledby: null,
        monitoringFilledtime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询监察对象表列表 */
    getList() {
      this.loading = true;
      listMonitoringmanList(this.queryParams).then(response => {
        this.monitoringmanListList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        monitoringmanName: null,
        monitoringSex: null,
        monitoringBri: null,
        monitoringNation: null,
        monitoringNative: null,
        monitoringWorktime: null,
        monitoringPolitical: null,
        monitoringJointime: null,
        monitoringRank: null,
        monitoringSocialposition: null,
        monitoringCategory: null,
        monitoringIdentity: null,
        monitoringExitpassport: null,
        monitoringDegreeofeducation: null,
        monitoringUniversity: null,
        monitoringCurrentposition: null,
        monitoringIdnumber: null,
        monitoringAddress: null,
        monitoringBiographicalnotes: null,
        monitoringPhonenum: null,
        monitoringFamilyTitle: null,
        monitoringFamilyName: null,
        monitoringFamilyAge: null,
        monitoringFamilyPolitical: null,
        monitoringFamilyWorkprofessional: null,
        monitoringCurrentpositionunit: null,
        monitoringFilledby: null,
        monitoringFilledtime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1; 
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.monitoringmanName)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加监察对象表";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const monitoringmanName = row.monitoringmanName || this.ids
      getMonitoringmanList(monitoringmanName).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改监察对象表";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.monitoringmanName != null) {
            updateMonitoringmanList(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addMonitoringmanList(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const monitoringmanNames = row.monitoringmanName || this.ids;
      this.$modal.confirm('是否确认删除监察对象表编号为"' + monitoringmanNames + '"的数据项？').then(function() {
        return delMonitoringmanList(monitoringmanNames);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/monitoringmanList/export', {
        ...this.queryParams
      }, `monitoringmanList_${new Date().getTime()}.xlsx`)
    },
    //下载二维码    
    handleDownloadQrCode(row) {
         const test = this.getList(row)
        console.log(test)
    },
  }
};
</script>
